home *** CD-ROM | disk | FTP | other *** search
/ Macmillan Math: Grade 1 …Pupil's Edition (Florida) / Math Grade 1 - Pupil's Edition (Florida).iso / pc / corsair / generic / javascript / tooltip.js < prev    next >
Encoding:
Text File  |  2004-07-07  |  1.9 KB  |  56 lines

  1. function showtip( current, e, text ) {
  2.  
  3.     if ( document.all ) {
  4.  
  5.         thetitle = text.split( '<br>' );
  6.  
  7.         if ( thetitle.length > 1 ) {
  8.  
  9.             thetitles ="";
  10.  
  11.             for ( i = 0; i < thetitle.length; i++ ) {
  12.  
  13.                thetitles += thetitle[i] + "\r\n";
  14.  
  15.                thetitles = removeHtmlTag(thetitles);
  16.  
  17.             }
  18.  
  19.             current.title = thetitles;
  20.  
  21.         } else {
  22.  
  23.             current.title = removeHtmlTag(text);
  24.  
  25.         }
  26.  
  27.     } else if ( document.layers ) {
  28.  
  29.         document.tooltip.document.open();
  30.  
  31.         document.tooltip.document.write('<span style="border:1px solid black;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#000000;">' + text + '</span>');
  32.  
  33.         document.tooltip.document.close();
  34.  
  35.         document.tooltip.left = e.pageX + 10;
  36.  
  37.         document.tooltip.top = e.pageY + 10;
  38.  
  39.         document.tooltip.visibility = "show";
  40.  
  41.     }else if ( document.getElementById("tooltip") ) {
  42.                         
  43.         document.getElementById("tooltip").style.left = e.pageX + 10;
  44.  
  45.         document.getElementById("tooltip").style.top = e.pageY + 10;
  46.  
  47.         document.getElementById("tooltip").style.visibility = "visible";
  48.         document.getElementById("tooltip").innerHTML= '<span style="border:1px solid black;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#000000;">' + text + '</span>';
  49.     }
  50.     
  51.  
  52. }
  53.  
  54.  
  55.  
  56. // remove the html tag from the string str
  57.  
  58. function removeHtmlTag(str)
  59.  
  60. {
  61.  
  62.     while (true)
  63.  
  64.     {
  65.  
  66.         start = str.indexOf("<");
  67.  
  68.         end = str.indexOf(">", start);
  69.  
  70.  
  71.  
  72.         if (start != -1 && end != -1) // find a tag
  73.  
  74.         {
  75.  
  76.             str = str.substr(0, start) + str.substring(end + 1, str.length);
  77.  
  78.         }
  79.  
  80.         else 
  81.  
  82.         {
  83.  
  84.             break; //did not find one
  85.  
  86.         }
  87.  
  88.     }
  89.  
  90.  
  91.  
  92.     return str;
  93.  
  94. }
  95.  
  96.  
  97.  
  98. function hidetip() {
  99.  
  100.     if (document.layers) {
  101.  
  102.         document.tooltip.visibility = "hidden";
  103.  
  104.     }
  105.  
  106. }
  107.  
  108.